﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;

namespace GZ.Entity
{
    public class EComment
    {
        #region 属性
        private int _id;

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        private int _productid;

        public int ProductId
        {
            get { return _productid; }
            set { _productid = value; }
        }
        private DateTime _createdate;

        public DateTime CreateDate
        {
            get { return _createdate; }
            set { _createdate = value; }
        }
        private int _customerid;

        public int CustomerId
        {
            get { return _customerid; }
            set { _customerid = value; }
        }
        private string _customertelnum;

        public string CustomerTelNum
        {
            get { return _customertelnum; }
            set { _customertelnum = value; }
        }
        private string _customeremail;

        public string CustomerEmail
        {
            get { return _customeremail; }
            set { _customeremail = value; }
        }
        private int _replaycommentid;

        public int ReplayCommentId
        {
            get { return _replaycommentid; }
            set { _replaycommentid = value; }
        }
        private bool _isaudit;

        public bool IsAudit
        {
            get { return _isaudit; }
            set { _isaudit = value; }
        }
        private string _commentcontent;

        public string CommentContent
        {
            get { return _commentcontent; }
            set { _commentcontent = value; }
        }
        private bool _isdelete;

        public bool IsDelete
        {
            get { return _isdelete; }
            set { _isdelete = value; }
        }

        #endregion

        public EComment()
        {
            this._createdate = DateTime.Now;
            this._isaudit = false;
            this._isdelete = false;
        }

        /// <summary>
        /// 添加新评论
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>是否成功</returns>
        public bool Insert(Entity.EComment obj)
        {
            string sql = @"INSERT INTO  tb_ProductComment
                            ( 
                            ProductId,
                            CreateDate,
                            CustomerId,
                            CustomerTelNum,
                            CustomerEmail,
                            ReplayCommentId,
                            IsAudit,
                            CommentContent,
                            IsDelete)
                            VALUES
                            ( 
                            @ProductId,
                            @CreateDate,
                            @CustomerId,
                            @CustomerTelNum,
                            @CustomerEmail,
                            @ReplayCommentId,
                            @IsAudit,
                            @CommentContent,
                            @IsDelete
                            );";
            MySqlParameter[] parameters = new MySqlParameter[9];
            parameters[0] = new MySqlParameter("@ProductId", obj.ProductId);
            parameters[1] = new MySqlParameter("@CreateDate", obj.CreateDate);
            parameters[2] = new MySqlParameter("@CustomerId", obj.CustomerId);
            parameters[3] = new MySqlParameter("@CustomerTelNum", obj.CustomerTelNum);
            parameters[4] = new MySqlParameter("@CustomerEmail", obj.CustomerEmail);
            parameters[5] = new MySqlParameter("@ReplayCommentId", obj.ReplayCommentId);
            parameters[6] = new MySqlParameter("@IsAudit", obj.IsAudit);
            parameters[7] = new MySqlParameter("@CommentContent", obj.CommentContent);
            parameters[8] = new MySqlParameter("@IsDelete", obj.IsDelete);
            return MySqlHelper.ExecuteNonQuery(GZ.DAL.MySQLHelper.connStr, sql, parameters) > 0 ? true : false; ;
        }


    }
}
